package com.example.dict.ativities;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ExpandableListView;

import com.example.dict.R;
import com.example.dict.adapter.SearchLeftAdapter;
import com.example.dict.bean.pinbuBean;
import com.example.dict.bean.pinbuWordBean;
import com.example.dict.db.DBManager;
import com.example.dict.utils.ApiUtil;
import com.example.dict.utils.AssetsUtil;
import com.example.dict.utils.CommonUtil;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;

import java.util.ArrayList;
import java.util.List;


public class QueryPinyinActivity extends BaseSearchActivity {

    String Url;//获取拼音对应的文字网址
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData(CommonUtil.FILE_PINYIN,CommonUtil.TYPE_PINYIN);
        setExLvListenr(CommonUtil.TYPE_PINYIN);
        mExpandableListView.expandGroup(0);
        Word = "a";
        Url = ApiUtil.getPinyinurl(Word,Page,PageSize);
        //加载数据
        loadData(Url);
        setGVListener(CommonUtil.TYPE_PINYIN);//下拉刷新，上拉加载
    }

    /**
     * 网络获取数据失败时会调用
     * 注意：拼音查询和部首查询获取的方法分开写，所以onError方法写到子类中
     * @param ex
     * @param isOnCallback
     */

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        List<pinbuWordBean.ResultBean.ListBean> list = DBManager.queryPyWordFromPyWord(Word, Page, PageSize);
        refreshDataByGv(list);

    }


}
